<template>
	<view class="tab-bar">
		<view v-for="(item,index) in list" :key="index" class="tab-bar-item" @click="switchTabFn(item, index)">
			<image class="tab_img" :src="select == index ? item.selectedIconPath : item.iconPath"></image>
			<view class="tab_text" :style="{color: select == index ? selectedColor : color}">{{item.text}}
			</view>
		</view>
	</view>

</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		props: {
			select:Number
		},
		data() {
			return {
				color: "#000000",
				selectedColor: "#4053CD",
				list: [{
					"pagePath": "/pages/index/index",
					"iconPath": "/static/tabs/tab1.png",
					"selectedIconPath": "/static/tabs/tabs1_1.png",
					"text": "首页"
				}, {
					"pagePath": "/pages/work_list/work_list",
					"iconPath": "/static/tabs/tab3.png",
					"selectedIconPath": "/static/tabs/tab3-3.png",
					"text": "工单管理"
				}, {
					"pagePath": "/pages/my/my",
					"iconPath": "/static/tabs/tabs2.png",
					"selectedIconPath": "/static/tabs/tab2_2.png",
					"text": "个人中心"
				}]
			}
		},
		watch: {
			$route(o, n) {
				console.log(o, n,15);
			}
		},
		computed: {
			...mapState(['tabbarSelectIndex'])
		},
		methods: {
		
			switchTabFn(item, index) {
				
				let url = item.pagePath;

				uni.switchTab({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab-bar {
		z-index: 9999999999999999999999999;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
		background: white;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
		box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1);

		.tab-bar-item {
			flex: 1;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;

			.tab_img {
				width: 37rpx;
				height: 41rpx;
			}

			.tab_text {
				font-size: 20rpx;
				margin-top: 9rpx;
			}
		}
	}
</style>
